<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:sf="http://www.springframework.org/tags/faces"
	template="/WEB-INF/layouts/standard.xhtml">

	<ui:define name="content">
	
	<ui:fragment id="resultFragment">
		<div class="res">
		<h3>Результаты - #{results.tourName}</h3>
		<h:form id="result">
			<ui:fragment id="searchResultsFragment">
				<div id="searchResults">
				    <h:outputText id="noText"
					value="Результаты будут доступны после начала тура"
					rendered="#{results.currentTourId &lt; thistourid}" />

					<ui:fragment rendered="#{results.currentTourId >= thistourid}">
						<table border="1" class="summary">
							<thead><tr>
								<td class="colUser">
									<h:outputText escape="false" value="Место"/>
								</td>
								<td class="colUser">
									<h:outputText escape="false" value="Участник"/>
								</td>
								<td class="colUser">
									<h:outputText escape="false" value="Всего очков #{u.pointsTour}"/>
								</td>
								<ui:repeat value="${results.matches}" var="m">
								<td class="colPlace">
									<a target="_blank" href="#{m.match.matchurl}">
									<h:outputText escape="false" value="#{m.match.team1.teamname}"/>
									<br />
									<img src="${request.contextPath}/imageservlet?teamid=#{m.match.team1.teamid}"/>
									<br />
									<h:outputText escape="false" value="#{m.match.team2.teamname}"/>
									<br />
									<img src="${request.contextPath}/imageservlet?teamid=#{m.match.team2.teamid}"/>
									</a>
									<br />
									<ui:fragment rendered="#{results.isAdmin}">
									<sf:commandLink id="editScore1" action="editscore" processIds="*">
										<f:param name="matchid" value="#{m.match.matchid}" />
										<h:graphicImage url="/resources/images/EditIcon.gif"/>
									</sf:commandLink>
									</ui:fragment>
									<br />
									<h:outputText escape="false" value="#{m.match.score1}:#{m.match.score2}"/>
								</td>							
								</ui:repeat>
							</tr></thead>
							<ui:repeat value="#{results.users}" var="u">
							<tr>
								<td class="colPlace">
									<h:outputText escape="false" value="#{u.placeTour}" style="color:#{u.placeTour == 1 ? 'darkred' : 'black'}"/>
								</td>
								<td class="colUser">
									<h:outputText escape="false" value="#{empty currentUser.name?u.username:u.fullname}" style="color:#{u.placeTour == 1 ? 'darkred' : 'black'}"/>
								</td>
								<td class="colTotal">
									<h:outputText escape="false" value="#{u.pointsTour}" style="color:#{u.placeTour == 1 ? 'darkred' : 'black'}"/>
								</td>
								<ui:repeat value="#{u.matches}" var="m">
								<td class="colCenter">
									<h:outputText escape="false" value="#{m.score1}:#{m.score2}"/>
								</td>							
								</ui:repeat>
							</tr>
						</ui:repeat>
						</table>
					</ui:fragment>
				</div>
			</ui:fragment>
		</h:form></div>
	</ui:fragment>
	
	</ui:define>
</ui:composition>